import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:myflutterproject/routes.dart';

/**
 * 启动页
 */
class Splash extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _SplashState();
}

class _SplashState extends State<Splash> {
  late Timer _mtimer;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Image.asset(
        'images/qd1.png',
        width: double.infinity,
        height: double.infinity,
        fit: BoxFit.fill,
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    //隐藏状态栏和导航栏  //设置不显示Gebug
    //       debugShowCheckedModeBanner: false,
    SystemChrome.setEnabledSystemUIOverlays([]);
    print('initState');
    //倒计时跳转
    _mtimer = Timer.periodic(Duration(seconds: 5), (t) {
      setState(() {
        Navigator.of(context).pushReplacementNamed(menuPage);
        // Navigator.of(context).pushReplacementNamed(homePage);
      });
    });
  }
  @override
  void dispose() {
    _mtimer.cancel();
    //恢复状态栏和导航栏   不恢复的话后面的页面也没有状态栏展示
    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
    super.dispose();
  }
}
